<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
     
    <!DOCTYPE html>
<html>
	<head>
	<style type="text/css">
	.order-list table a{
		color:blue;
	}
	</style>
	     <script src="${ctxWebStatic }/laydate/laydate.js"></script>
		<meta name="decorator" content="center_common" />
			<script>
	$(function(){
		
	    $(".parts_search_list i").click(function(){
		    if($(this).hasClass('search_chose_hover')){
			 	$(this).removeClass('search_chose_hover');
			}else{
				 	$(this).addClass('search_chose_hover');
			}
			var vv=$('.parts_search_list i').index($(this));		
			$(".numRadio").find('input').eq(vv).click();
		});
		
		var myDate = new Date();
		//获取当前年
		var year=myDate.getFullYear();
		//获取当前月
		var month=myDate.getMonth()+1;
		//获取当前日
		var date=myDate.getDate(); 
		if(month==1){
			var lastMonth = 12;
			var lastYear = year-1;
		}else{
			var lastYear = year;
			var lastMonth = month;
		}
		$('#test6').focus(function(){
			//$("#test6").val();
		  	$(this).val();
		}); 
		laydate.render({
			  elem: '#test6',
			  format:'yyyy-MM-dd',
			  range: true,
			  done: function(value, date, endDate){
		 		$("#test6").val(value);
			  	$("#forms").submit(); 
			  }
		});
		
		$(".js_pos_item input").click(function(){
			$(".js_pos_item").removeClass("pos_strangle");
		})

	    /* pc端订单状态切换*/
	  	tabOrder($(".ord-list-box .order-state-item"),$(".order-data .order-list"));
		/* 移动端订单状态切换 */
		tabOrder($(".ph-order-tab .order-item"),$(".ph-ord-list"));
		/* 切换公共方法 */
		function tabOrder(obj,oList){
			obj.on("click", function(){
				var _index = $(this).index();
				$(this).addClass("active").siblings().removeClass("active");
				oList.hide().first().show();
				oList.eq(_index).show().siblings().hide();
			})
		}
	})
	
	
	$(function(){
		/* var st=$("#pay").val(); */
		var goodsName=$("#goods").val();
		
		if(goodsName!=null&& goodsName!=''){
			$("#goodsName").val(goodsName)
		}
		/* if(st!=null&& st!=''){
		$("#test6").val($("#pay").val());
		}
		
		var storeName=$("#stores").val();
		if(storeName!=null && storeName!=''){
		$("#buyStoreName option").each(function(){
			if($(this).val()==storeName){
				$(this).attr("selected","selected"); 
			}	
		})	
		} 
		
		
		var status=$("#status").val();
		if(status!=null && status!=''){
		$("#state option").each(function(){
			if($(this).val()==status){
				$(this).attr("selected","selected"); 
			}	
		})	
		}  */
	})
	
   $(function(){
	   var st=$("#pages").val();
	   $(".ord-list-box").find("li").eq(st).addClass("active");
	   $(".ph-order-tab").find("li").eq(st).addClass("active");
   })
   
   function submits(){
		$("#forms").submit();
	}
   
	
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
    	return false;
	}
	$(function(){
		var scrollLock=0;
		var p=2;
		var createDate=$("#pay").val();
		var goodsName=$("#goods").val();
		var buyStoreName=$("#stores").val();
		var state=$("#status").val();
		$(window).scroll(function() {    
	     if ($(this).scrollTop() + window.innerHeight + 20 >= $(document).height() && $(this).scrollTop() >20) {
			  $("#loadingTips").show(); 
			  if(scrollLock==0){
				  scrollLock=1;
				  $.post("${ctxWeb}/order/selectPhoneList",{"p":p,"createDate":createDate,"goodsName":goodsName,"buyStoreName":buyStoreName,"state":state},function(e){
						if(e.length<2450){
							$("#loadingTips").text("已无更多数据")
						}else{
							$(".ph-ord-list").append(e);
							scrollLock=0;
							p = p+1;
						}
				  });
			 }
	      }  
	  }); 
	}) 
	
    </script>
	</head>
	<body>
	<input id="goods" value="${goodsName}" type="hidden"/>
	<input id="stores" value="${buyStoreName}" type="hidden"/>
	<input id="status" value="${status}" type="hidden"/>
	<input value="${createDate }" id="pay" type="hidden"/>
	<!--导航结束-->
	<!--主题内容-->
	<div class="parts_main_box bgf5">
		<div class="container">
			<div class="row">
				<!-- pc 订单管理 -->
				<div class="pc-order-part clearfix">
					<!-- 右边部分 -->
					<div class="col-sm-10 pad20">
						<div class="order-listinfo">
							<div class="order-state clearfix">
								<ul class="ord-list-box">
									<li class="order-state-item "><a href="${ctxWeb}/order/myOrder?pages=0">全部订单</a></li>
									<li class="order-state-item"><a href="${ctxWeb}/order/myOrder?state=1&pages=1">待付款</a></li>
									<li class="order-state-item"><a href="${ctxWeb}/order/myOrder?state=2&pages=2">待发货</a></li>
									<li class="order-state-item"><a href="${ctxWeb}/order/myOrder?state=3&pages=3">部分发货</a></li>
									<li class="order-state-item"><a href="${ctxWeb}/order/myOrder?state=4&pages=4">全部发货</a></li>
									<li class="order-state-item"><a href="${ctxWeb}/order/myOrder?state=5&pages=5">已完成</a></li>
								</ul>
								<form id="forms" action="${ctxWeb}/order/myOrder" method="post">
								<div class="search-part">
									<input class="form-control state-search" type="text" placeholder="请输入您要搜索订单号" name="orderCode" id="goodsName">
									<a class="confirm-btn" href="javascript:;"  onclick="submits()"></a>
								</div>
							</div>
							   <input name="pages" value="${pages }" id="pages" type="hidden" />
							<div class="order-data">
								<!-- pc表格列表 -->
								<div class="order-list">
									<table class="table">
										<thead>
											<tr>
												<td class="col-xs-3 pad0">
													<p class=" js_pos_item">
														<input type="text" class="demo-input trian-down hy1 select_table"  value="订单日期筛选" id="test6"  name="createDate">
													</p>
												</td>
												<td><p>订单编号</p></td>
												<td>
													<p>													
														<select class="trian-down hy1 select_table" name="buyStoreName" id="buyStoreName" onchange="submits()">
														    <option value="">卖家</option>
															<c:forEach var="store" items="${storeList }">
															<option value="${store.buyStoreCode }">${store.buyStoreName }</option>
															</c:forEach>
														</select>
													</p>
												</td>
												<td><p>订单金额</p></td>
												<td><p>支付方式</p></td> 
												<td>
													<p>
														<select class="trian-down hy1 select_table" name="state" id="state" onchange="submits()">
															<option value="">状态</option>
															<option value ="1">待付款</option>
															<option value ="2">待发货</option>
															<option value ="3">部分发货</option>
															<option value ="4">全部发货</option>
															<option value ="5">已完成</option>
															<option value ="6">已取消</option>
															<option value ="7">异常</option>
														</select>
													</p>
												</td>
											</tr>
										</thead>
										</form>
										<tbody>
										    <c:forEach var="list"    items="${list }">
											 <tr>
												<td><p><fmt:formatDate value="${list.createDate}" pattern="yyyy-MM-dd HH:mm"/></p></td>
												
												<td><p>
											    <c:if test="${list.orderType!=2 }">
												<a class="orderCodeLink" target="_blank" href="${ctxWeb}/order/orderDetail?ordersCode=${list.code }&transportType=${list.transportType}&id=${list.id}">${list.code }</a>
												</c:if>
												 <c:if test="${list.orderType==2 }">
												<a class="orderCodeLink" target="_blank" href="${ctxWeb}/goodsComb/detail?id=${list.id }&storeCode=${list.code }">;</a>
												</c:if>
												</p></td>
												
												<td><p>${fns:getDictLabel(list.type, 'store_type', '')}:
												<span>${list.buyStoreName }</span></p></td>
												<td><p class="darkred">¥<span class="sum">${list.payMoney}</span></p></td>
												<td><p>${fns:getDictLabel(list.payType, 'pay_type', '')}</p></td>
												<td><p>${fns:getDictLabel(list.state, 'orders_state', '')}</p></td>
											</tr>
											</c:forEach>
										</tbody>
									</table>
								</div>
								<!-- pc表格列表 -->
								<div class="order-list">
								</div>
								<!-- pc表格列表 -->
								<div class="order-list">
								</div>
								<!-- pc表格列表 -->
								<div class="order-list">
								</div>
								<!-- pc表格列表 -->
								<div class="order-list">
								</div>
								<!-- pc表格列表 -->
								<div class="order-list">
								</div>
							</div>
							<form:form id="searchForm" modelAttribute="webOrders" action="${ctxWeb}/order/myOrder" method="post" class="">
								<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
								<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
							</form:form>
							<div class="pagination">${page}</div>
						</div>
					</div>
					<!-- 右边部分 end-->
				</div>
				<!-- pc 订单管理 end -->
				<!-- 手机端 订单管理 -->
				<div class="phone-order-part">
					<div class="ph-order-state">
						<ul class="ph-order-tab clearfix">
							<li class="order-item "><a href="${ctxWeb}/order/myOrder?pages=0">全部订单</a></li>
							<li class="order-item"><a href="${ctxWeb}/order/myOrder?state=1&pages=1">待付款</a></li>
							<li class="order-item"><a href="${ctxWeb}/order/myOrder?state=2&pages=2">待发货</a></li>
							<li class="order-item"><a href="${ctxWeb}/order/myOrder?state=4&pages=3">全部发货</a></li>
							<li class="order-item"><a href="${ctxWeb}/order/myOrder?state=5&pages=4">已完成</a></li>
						</ul>
						<div class="ph-ord-details">
							<div class="ph-ord-list">
							   <c:forEach var="list" items="${listPhone }">
								<div class="ph-list-item">
									<table>
										<thead>
											<tr>
												<td><p>订单编号</p></td>
												<td><p>卖家</p></td>
												<td><p>订单金额</p></td>
												<td><p>支付方式</p></td>
												<td><p>订单状态</p></td>
												<td><p>下单日期</p></td>
											</tr>
										</thead>	
										<tbody>
											<tr>
												<td><p>
												 <c:if test="${list.orderType!=2 }">
												<a target="_blank" style="color:blue" href="${ctxWeb}/order/orderDetail?ordersCode=${list.code }&transportType=${list.transportType}&id=${list.id}">${list.code }</a>
												</c:if>
												 <c:if test="${list.orderType==2 }">
												<a target="_blank" style="color:blue" href="${ctxWeb}/goodsComb/detail?id=${list.id }&storeCode=${list.code }">;</a>
												</c:if>
												</p></td>
												<td><p>${fns:getDictLabel(list.type, 'store_type', '')}:${list.buyStoreName }
												</p></td>
												<td><p><em>¥</em>${list.payMoney }</p></td>
												<td><p>${fns:getDictLabel(list.payType, 'pay_type', '')}</p></td>
												<td><p>${fns:getDictLabel(list.state, 'orders_state', '')}</p></td>
												<td><p><fmt:formatDate value="${list.createDate}" pattern="yyyy-MM-dd"/></p></td>
											</tr>
										</tbody>
									</table>
								</div>
								</c:forEach>
						</div>
						<p style='text-align:center;padding:0.5rem 0;display:none;' id='loadingTips'>正在加载...</p>
					</div>
				</div>
				<!-- 手机端 订单管理 end-->
			</div>
		</div>
	</div>
	<!--主题内容-->
	</body>
</html>
